#!/usr/bin/env groovy
import static javax.swing.JOptionPane.*
import twitter4j.*         

def username = showInputDialog( view, "username?", "" )
def password = showInputDialog( view, "password?", "" )

def text = textArea.selectedText?:textArea.text
def message = """\
[update ?]
-----------------------------------------
${text}
"""

if( showConfirmDialog( view, message) != YES_OPTION )
    return

def twitter = new Twitter(username, password)
def status = twitter.update(textArea.text)
showMessageDialog( view, "update complete." )
